﻿using Harmontronics.DataAccess.IOperate.Business;
using Harmontronics.Model.Common;
using Harmontronics.Model.Dto.Model;
using Harmontronics.Model.Entitys;
using Harmontronics.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Harmontronics.DataAccess.Operate.Business
{
    public class ProductionLineOperate : IProductionLineOperate
    {
        private HcDbContext _db { get; set; }
        public ProductionLineOperate(HcDbContext db)
        {
            _db = db;
        }
        //查询所有
        public List<ProductionLine> GetAllProductionLineList()
        {

            return _db.ProductionLines.ToList();
        }

        public ProductionLine GetProductionLineById(string id)
        {
            return _db.ProductionLines.SingleOrDefault(i => i.ProductionLineId == id);
        }

        public List<ProductionLine> GetProductionLineByIdList(List<string> ids)
        {
            return _db.ProductionLines.Where(i => ids.Contains(i.ProductionLineId)).ToList();
        }
        public List<ProductionLine> GetProductionLineByWorkShopId(string id)
        {
            return _db.ProductionLines.Where(i => i.WorkShopId == id).ToList();
        }
        
        public void AddProductionLine(ProductionLine entity)
        {
            _db.ProductionLines.Add(entity);
        }

        public void UpdateProductionLine(ProductionLine entity)
        {
            _db.ProductionLines.Update(entity);
        }

        public void DeleteProductionLine(ProductionLine entity)
        {
            _db.ProductionLines.Remove(entity);
        }

        public void BatchDelProductionLine(List<ProductionLine> entity)
        {
            _db.ProductionLines.RemoveRange(entity);

        }
    }
}
